package com.mysterymall.Controller;

import com.google.zxing.WriterException;
import com.mysterymall.Common.Comp.Log;
import com.mysterymall.Common.Utils.Result;
import com.mysterymall.Service.TeamService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.math.BigDecimal;

/**
 * @ClassName com.mysterymall.Controller
 * @Description
 * @Author HuangWX
 * @Time 2023/12/05  13:17
 */
@RestController
@RequestMapping("/team")
public class TeamController {

    private final TeamService teamService;

    /**
     * 构造器注入
     * @param teamService 团队服务
     */
    public TeamController(TeamService teamService) {
        this.teamService = teamService;
    }

    /**
     * 获取佣金明细
     * @return Result
     */
    @GetMapping("/getMyBrokerageDetail")
    @Log
    public Result getMyBrokerageDetail(@RequestParam("currIndex") Integer currIndex, @RequestParam("pageSize") Integer pageSize){
        return teamService.getMyBrokerageDetail(currIndex,pageSize);
    }

    /**
     * 获取我的团队列表
     * @return Result
     */
    @GetMapping("/getMyTeamList")
    @Log
    public Result getMyTeamList(){
        return teamService.getMyTeamList();
    }

    /**
     * 邀请好友(二维码)
     * @return Result
     */
    @GetMapping("/invite")
    @Log
    public Result Invite(@RequestParam("rootUrl") String rootUrl) throws IOException, WriterException {
        return teamService.getInVite(rootUrl);
    }


    /**
     * 佣金转幸运币
     * @return Result
     */
    @GetMapping("/convert")
    @Log
    public Result convert(@RequestParam("amount") BigDecimal amount) {
        return teamService.luckyCoinPayment(amount);
    }


    @GetMapping("/addStaff")
    @Log
    public Result addStaff(@RequestParam("teamUserId") String teamUserId,@RequestParam("userName")String userName) {
        return teamService.addStaff(teamUserId,userName);
    }
}
